#include "ClientSocket.h"
#include "SocketException.h"
#include <iostream>
#include <string>
#include "vector_serialization.h"
int main ( int argc, char *argv[] )
{
  try
    {

      ClientSocket client_socket ( "localhost", 30000 );

      std::string reply;
	  std::string sendmsg;
	  while (true) {
      try
	  {
		//getline(std::cin,sendmsg);
		//std::cin >> sendmsg;
		string name, sex, age,code;
		map<string, string> smap;
		cout << "code:";
		cin >> code;
		cout << "name:";
		cin >> name;
		cout << "sex:";
		cin >> sex;
		cout << "age";
		cin >> age;
		smap["code"] = code;
		smap["name"] = name;
		smap["sex"] = sex;
		smap["age"] = age;
		sendmsg = save(smap);
		client_socket << sendmsg;
		
		client_socket >> reply;
		cout << "reply:" << reply << endl;
		//vector<string> recv;
		//load(reply,recv);
		//for (vector<string>::iterator it = recv.begin(); it != recv.end(); ++it)
			//cout << *it << " ";
	  }
      catch ( SocketException& ) {}

      //std::cout << "We received this response from the server:\n\"" << reply << "\"\n";;

    }
	}
  catch ( SocketException& e )
    {
      std::cout << "Exception was caught:" << e.description() << "\n";
    }

  return 0;
}
